package type.conversion;

public class ConverionUtil {

    public static int byte2int(byte b) {
        int result;
        result = b;
        return result;
    }

    public static byte int2byte(int i) {
        byte result;
        result = (byte) i;
        return result;
    }
    
    /**
     * @param args
     */
    public static void main(String[] args) {
        byte b;
        int i;
        
        b= 127;
        System.out.println(byte2int(b));
        
        i = 128;
        // here we use a force conversion, and the result is correct.
        b = int2byte(i);
        Byte bw= b;
        System.out.println(bw);
        
        // here we demonstrated how phase a string to int.
        // and that works. For more details, we can explore
        // the Integer.decode().
        String num = "0x80";
        System.out.println(Integer.decode(num).byteValue());
    }

}
